<?php
/**
* Remove a particular thumbnail
*/

$image_id = $variable->get('id', 'integer', 0);
$size_id = $variable->get('size', 'integer', 0);

$images = new images();
$album_id = $images->album_id($image_id);

if($size_id == THUMBNAIL_ORIGINAL_SIZE_ID)
{
	# Preserve originally scanned images
	$messenger = new messenger('error', 'Cannot remove originally scanned images');
}
else
{
	$thumbnail_file = realpath(FTPPATH_THUMBNAILS."/{$album_id}/{$size_id}/{$image_id}.jpg");
	if(is_file($thumbnail_file))
	{
		if(unlink($thumbnail_file))
		{
			$messenger = new messenger('notice', 'The thumbnail is removed.');
		}
		else
		{
			$messenger = new messenger('error', 'Could not remove the thumbnail. Please remove it manually.');
		}
	}
	else
	{
		$messenger = new messenger('error', 'The thumbnail file did not exist earlier.');
	}
}
#print_r($_GET);
#die("Removing: {$album_id}/{$size_id}/{$image_id}.jpg");

stopper::url(headers::back('images-list.php'));
?>